﻿using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace CustomsDocumentOA.Project.QRCode
{
    public class QRCodeService : IQRCodeService
    {
        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <param name="plainText">扫描二维码时显示的内容</param>
        /// <param name="pixel">像素</param>
        /// <returns></returns>
        public Bitmap GetQRCodeInfo(string plainText, int pixel)
        {
            var generator = new QRCodeGenerator();
            var qrCodeData = generator.CreateQrCode(plainText, QRCodeGenerator.ECCLevel.Q);
            var qrCode = new QRCoder.QRCode(qrCodeData);

            var bitmap = qrCode.GetGraphic(pixel);

            return bitmap;
        }
    }
}
